#ifndef __QUANTITY_H__
#define __QUANTITY_H__

#include <UnitType.h>
#include <string>

using namespace std;

class Unit;

template <class TUnit>
class Quantity
{
    public:
        Quantity(Uint32 amount, const TUnit& unitType):amount_m(amount),unitType_m(unitType)
        {
        }
        
	Uint32 toBase() const
        {
                return amount_m * unitType_m.toBase();
        }

        bool operator == (const Quantity & rhs) const
        {
                return (toBase() == rhs.toBase());
        }

        bool operator != (const Quantity & rhs) const
        {
                return (toBase() != rhs.toBase());
        }

        Quantity operator / (const TUnit& unitType) const
        {
                return Quantity(toBase()/unitType.toBase(),unitType);
        }
       
        Quantity operator % (const TUnit& unitType) const
        {
                return Quantity(toBase()%unitType.toBase(),TUnit::getBaseUnit());
        }
       
        Quantity operator + (const Quantity & rhs) const
        {
                return Quantity(toBase()+rhs.toBase(),TUnit::getBaseUnit());
        }

    protected:
        Uint32 amount_m;
        const TUnit& unitType_m;
        string unitName_m;
};

#endif


